<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Users
 *
 * This model represents user authentication data. It operates the following tables:
 * - user account data,
 * - user profiles
 *
 * @package	Sama Manager
 * @author	William Mandai (http://willymandai.com)
 */
class News_Model extends CI_Model
{
	
	function get_news()
	{
		//$this->db->where('activated', $activated ? 1 : 0);
		$this->db->join('users','users.id = news.author');
		$query = $this->db->get('news');
		if ($query->num_rows() > 0){
			return $query->result_array();
		} 
	}
	function active_news()
	{
		$this->db->where('expiry_date >=',time());
		$query = $this->db->get('news');
		if ($query->num_rows() > 0){
			return $query->result_array();
		} 
	}
	function get_subscribers()
	{
		$query = $this->db->get('subscribers');
		if ($query->num_rows() > 0){
			return $query->result_array();
		} 
	}
function check_subscriber($email)
	{
		$this->db->where('sub_email', $email);
		$query = $this->db->get('subscribers');
		if ($query->num_rows() > 0){
			return TRUE;
		} else {
			return FALSE;
		}
	}
function get_news_details($news)
	{
		$this->db->where('news_id', $news);
		$this->db->join('users','users.id = news.author');
		$query = $this->db->get('news');
		if ($query->num_rows() > 0){
			return $query->result_array();
		} 
	}
	function get_sub_details($sub)
	{
		$this->db->where('sub_id', $sub);
		$query = $this->db->get('subscribers');
		if ($query->num_rows() > 0){
			return $query->result_array();
		} 
	}
	
	 public function messages() {
        $_output = '';
        foreach ($this->messages as $message) {
            $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##';
            $_output .= $this->message_start_delimiter . $messageLang . $this->message_end_delimiter;
        }

        return $_output;
    }
	
	
}

/* End of file users.php */
/* Location: ./application/models/auth/users.php */